problem solving javascript